import { Component, OnInit } from '@angular/core';
import { NzModalService } from 'ng-zorro-antd';
import { OprationService } from 'src/app/service/opration.service';
import { RechargeService } from 'src/app/service/recharge.service';

@Component({
  selector: 'app-offline-pay-log',
  templateUrl: './offline-pay-log.component.html',
  styleUrls: ['./offline-pay-log.component.less']
})
export class OfflinePayLogComponent implements OnInit {

  datalist: any[] | null = null;
  isLoading: boolean = false;
  totalCount: number;
  selectData: any = {
    type: '转账汇款',
    pagesize: 10,
    pageindex: 1
  };
  statusText = ['待处理', '已处理'];

  getlist() {
    this.isLoading = true;
    this.rechargeService.page(this.selectData).subscribe(result => {
      this.isLoading = false;
      this.totalCount = result['data']['count'];
      this.datalist = result['data']['items'];
    });
  }

  delete(id: number) {
    this.modalService.confirm({
      nzTitle: '信息提示',
      nzContent: '确定要删除此单据吗？',
      nzClosable: false,
      nzOnOk: () => {
        this.rechargeService.delete(id).subscribe(result => {
          this.oprationService.tips(result, '单据删除成功');
          this.getlist();
        });
      }
    });
  }

  constructor(
    private rechargeService: RechargeService,
    private modalService: NzModalService,
    private oprationService: OprationService
  ) { }

  ngOnInit(): void {
    this.getlist();
  }

}
